home *** CD-ROM | disk | FTP | other *** search
INI File | 2001-09-10 | 3.3 KB | 55 lines |
- [Name]
- RandomCrawl - From Matthew's Motion Suite.
- By Matthew Peterson, matthew@pinoko.berkeley.edu
-
- [Description]
- 2-19-2000
- Drop this on a sprite, and crawl randomly around the sprite
- track.
-
- [Parameters]
-
-
- [Idle]
- SpriteVars MP_crawlstep MP_crawlstepx MP_crawlcorner MP_crawlstepy
- //Random Crawl By Matthew Peterson
- //This behavior is a simple play on Brownian motion with a more
- //organic feel. The sprite will stretch a random corner out in
- //a random direction, and pull the rest of the sprite over. The
- //ability to strech sprites in this way is underused.
-
- if(MP_crawlstep = 0) //first the corner stretches out
- MP_crawlstepx = random(1,5)//The stretch distance
- MP_crawlstepy = random(1,5)
- //Check if the sprite goes out of bounds. If it does, stretch in
- //The opposite direction
- if(boundstop < 0)
- MP_crawlcorner = 3
- elseif(boundsright > trackwidth)
- MP_crawlcorner = 4
- elseif(boundsbottom > trackheight)
- MP_crawlcorner = 1
- elseif(boundsleft < 0)
- MP_crawlcorner = 2
- else
- //If not out of bounds, stretch in a random direction
- MP_crawlcorner = (tickcount + random(1,45)) rem 4 + 1 //random corner. Used tickcount to get more variance on PCs
- endif
- //Stretch the corner again
- stretch(firstcornerx - MP_crawlstepx*2*(MP_crawlcorner=1),firstcornery- MP_crawlstepy*2*(MP_crawlcorner=1),secondcornerx + MP_crawlstepx*2*(MP_crawlcorner=2),secondcornery - MP_crawlstepy*2*(MP_crawlcorner=2), thirdcornerx + MP_crawlstepx*2*(MP_crawlcorner=3),thirdcornery+ MP_crawlstepy*2*(MP_crawlcorner=3),fourthcornerx- MP_crawlstepx*2*(MP_crawlcorner=4),fourthcornery+MP_crawlstepy*2*(MP_crawlcorner=4))
- elseif(MP_crawlstep = 1)
- stretch(firstcornerx - MP_crawlstepx*2*(MP_crawlcorner=1),firstcornery- MP_crawlstepy*2*(MP_crawlcorner=1),secondcornerx + MP_crawlstepx*2*(MP_crawlcorner=2),secondcornery - MP_crawlstepy*2*(MP_crawlcorner=2), thirdcornerx + MP_crawlstepx*2*(MP_crawlcorner=3),thirdcornery+ MP_crawlstepy*2*(MP_crawlcorner=3),fourthcornerx- MP_crawlstepx*2*(MP_crawlcorner=4),fourthcornery+MP_crawlstepy*2*(MP_crawlcorner=4))
- elseif(MP_crawlstep < 6)//Then the sprite pulls itself to its stretched corner in 5 steps.
- if(MP_crawlcorner = 1)//I could have done this all in one stretch command, but it would be harder to read, and take slightly more time to calculate.
- stretch(firstcornerx,firstcornery,secondcornerx- MP_crawlstepx,secondcornery- MP_crawlstepy,thirdcornerx- MP_crawlstepx,thirdcornery- MP_crawlstepy,fourthcornerx- MP_crawlstepx,fourthcornery- MP_crawlstepy)
- elseif(MP_crawlcorner = 2)
- stretch(firstcornerx + MP_crawlstepx,firstcornery - MP_crawlstepy,secondcornerx,secondcornery,thirdcornerx+MP_crawlstepx,thirdcornery- MP_crawlstepy,fourthcornerx+ MP_crawlstepx,fourthcornery- MP_crawlstepy)
- elseif(MP_crawlcorner = 3)
- stretch(firstcornerx + MP_crawlstepx,firstcornery + MP_crawlstepy,secondcornerx+MP_crawlstepx,secondcornery+MP_crawlstepy,thirdcornerx,thirdcornery,fourthcornerx+MP_crawlstepx,fourthcornery+MP_crawlstepy)
- elseif(MP_crawlcorner = 4)
- stretch(firstcornerx -MP_crawlstepx,firstcornery + MP_crawlstepy,secondcornerx- MP_crawlstepx,secondcornery+ MP_crawlstepy,thirdcornerx- MP_crawlstepx,thirdcornery+ MP_crawlstepy,fourthcornerx,fourthcornery)
- endif
- elseif(MP_crawlstep = 10)// Rest for a few idle events, and then start again.
- MP_crawlstep = - 1
- endif
- MP_crawlstep = MP_crawlstep + 1